<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('交易流水列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li class="select-time">
                                <p>交易日期：</p>
                                <input type="text" class="time-input" id="trDate" placeholder="必填" name="trDate" required/>
                            </li>
                            <li >
                                <p>机构号：</p>
                                <input name="brCode" required onclick="selectDeptTree()"  id="treeId" type="text" placeholder="请选择" class="form-control">
                            </li>
                            <li>
                                <p>柜员号：</p>
                                <input type="text" class="input-mini" style="width:60%" name="trTelr"/>
                            </li>
                            <li>
                                <p>交易码：</p>
                                <input type="text" class="input-mini" style="width:50%" name="txnCde"/>
                            </li>
                            <li>
                                <p>交易流水号：</p>
                                <input type="text" class="input-mini" style="width:30%" name="startVchNo"/>-
                                <input type="text" class="input-mini" style="width:30%" name="endVchNo"/>
                            </li>
                            <li>
                                <p>交易金额：</p>
                                <input type="text" class="input-mini" style="width:50%" name="txnAmt" />
                            </li>
                            <li>
                                <p>状态：</p>
                                <select name="filterFlag" th:with="type=${@dict.getType('paea_ds_trade_filter_flag')}" style="width:42%">
                                    <option value=0>所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="query()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>
            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="checkAll()" shiro:hasPermission="data:tradeOperate:checkAll">
                    <i class="fa fa-plus"></i>全选
                </a>
                <a class="btn btn-danger" onclick="checkInvert()" shiro:hasPermission="data:tradeOperate:unCheck">
                    <i class="fa fa-remove"></i>反选
                </a>
                <a class="btn btn-success" onclick="filteTrade()" shiro:hasPermission="data:tradeOperate:filterTrade">
                    <i class="fa fa-edit"></i> 处理流水
                </a>
                <a class="btn btn-info" onclick="openTrader()" shiro:hasPermission="data:tradeOperate:openTrade">
                    <i class="fa fa-check"></i> 还原流水
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="data:tradeOperate:export">
                    <i class="fa fa-download"></i> 导出
                 </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var filterTrade = [[${@permission.hasPermi('data:tradeOperate:filterTrade')}]];
        var openTrade = [[${@permission.hasPermi('data:tradeOperate:openTrade')}]];
        //var statusDatas = [[${@dict.getType('paea_ds_trade_status')}]];
        var filterFlagDatas = [[${@dict.getType('paea_ds_trade_filter_flag')}]];
        var prefix = ctx + "data/tradeOperate";
        function query() {
            if(!$.validate.form()){
                $.modal.alert("请输入查询条件");
            }else{
            $.table.destroy();
            var options = {
                url: prefix + "/list",
                exportUrl: prefix + "/export",
                modalName: "交易流水",
                showSearch: false,
                showRefresh: false,
                showToggle: false,
                showColumns: false,
                //启用跳转至指定页
                showPageGo: true,
                //启用点击选中行
                clickToSelect: true,
                //firstLoad:false,
                columns: [{
                    checkbox: true
                },
                    {
                        field: 'id',
                        title: '主键',
                        visible: false
                    },
                    {
                        field: 'trDate',
                        title: '交易日期'
                    },
                    {
                        field: 'txnTime',
                        title: '交易时间',
                        visible: false
                    },
                    {
                        field: 'brCode',
                        title: '机构号'
                    },
                    {
                        field: 'trTelr',
                        title: '柜员号'
                    },
                    {
                        field: 'txnSeq',
                        title: '交易流水号',
                        visible: false
                    },
                    {
                        field: 'vchNo',
                        title: '交易流水号'
                    },
                    {
                        field: 'ccyCode',
                        title: '货币码',
                        visible: false
                    },
                    {
                        field: 'accNo',
                        title: '账号'
                    },
                    {
                        field: 'txnAmt',
                        title: '交易金额'
                    },
                    {
                        field: 'txnCde',
                        title: '交易码'
                    },
                    {
                        field: 'filterFlag',
                        title: '状态',
                        formatter: function (value, row, index) {
                            return $.table.selectDictLabel(filterFlagDatas, value);
                        }
                    }/*,
                    {
                        title: '操作',
                        align: 'center',
                        formatter: function (value, row, index) {
                            var actions = [];
                            actions.push('<a class="btn btn-warning btn-xs ' + filterTrade + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>过滤</a> ');
                            actions.push('<a class="btn btn-success btn-xs ' + openTrade + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-check"></i>还原</a>');
                            return actions.join('');
                        }
                    }*/
                    ]
            };
            $.table.init(options);
            }
        }
        //选择机构
        function selectDeptTree() {
            var treeId = $("#treeId").val();
            var deptId = $.common.isEmpty(treeId) ? "00038" : $("#treeId").val();
            var url = ctx + "system/dept/selectDeptTree/" + deptId;
            var options = {
                title: '选择部门',
                width: "380",
                url: url,
                callBack: doSubmit
            };
            $.modal.openOptions(options);
        }
        function doSubmit(index, layero){
            var tree = layero.find("iframe")[0].contentWindow.$._tree;
            if ($.tree.notAllowParents(tree)) {
                var body = layer.getChildFrame('body', index);
                $("#treeId").val(body.find('#treeId').val());
                layer.close(index);
            }
        }
        function checkAll(){
            $('#bootstrap-table').bootstrapTable('checkAll');
        }
        function checkInvert(){
            $('#bootstrap-table').bootstrapTable('checkInvert');//uncheckAll全部取消
        }
        function filteTrade(){
            var ids = $.table.selectColumns("id");
            if(ids==''){
                alert("请选择需要处理的流水!");
            }else{
                var data = { "ids": ids.join() };
                $.operate.submit(prefix + "/filterTrade", "post", "json", data);
                //query();
            }
        }
        function openTrader(){
            var ids = $.table.selectColumns("id");
            if(ids==''){
                alert("请选择需要还原的流水!");
            }else{
                var data = { "ids": ids.join() };
                $.operate.submit(prefix + "/openTrade", "post", "json", data);
            }
        }

    </script>
</body>
</html>